package com.shop.service.impl;

import com.github.pagehelper.PageInfo;
import com.shop.entity.ProductAttributeValue;
import com.shop.mapper.ProductAttributeValueMapper;
import com.shop.service.ProductAttributeValueService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service("productAttributeValueService")
@RequiredArgsConstructor
@Transactional(rollbackFor = RuntimeException.class,
        propagation = Propagation.REQUIRED)
public class ProductAttributeValueServiceImpl implements ProductAttributeValueService {
    private final ProductAttributeValueMapper productAttributeValueMapper;
    @Override
    public PageInfo<ProductAttributeValue> listProductAttributeValue(int pageNum, int pageSize) {
        List<ProductAttributeValue> list = productAttributeValueMapper.listProductAttributeValue(pageNum, pageSize);
        return new PageInfo<>(list);
    }

    @Override
    public PageInfo<ProductAttributeValue> listWithProductAttributeValue(int pageNum, int pageSize) {
        List<ProductAttributeValue> list = productAttributeValueMapper.listWithProductAttributeValue(pageNum, pageSize);
        return new PageInfo<>(list);
    }

    @Override
    public ProductAttributeValue getProductAttributeValueById(Integer id) {
        return productAttributeValueMapper.getProductAttributeValueById(id);
    }

    @Override
    public void addProductAttributeValue(ProductAttributeValue productAttributeValue) {
        productAttributeValueMapper.addProductAttributeValue(productAttributeValue);
    }

    @Override
    public void deleteProductAttributeValue(Integer id) {
        productAttributeValueMapper.deleteProductAttributeValue(id);
    }

    @Override
    public void updateProductAttributeValue(Integer id, Integer attributeId, String value) {
        productAttributeValueMapper.updateProductAttributeValue(id, attributeId, value);
    }

    @Override
    public int getTotal() {
        return productAttributeValueMapper.getTotal();
    }
}
